package com.ms.game.slot.base;

import java.math.BigDecimal;

import com.xpec.c4.game.common.Helper;

public class SlotOfflineSpinInfoBase {
	
	public static final int NONE = 0;

	public static final int SPIN = 1;

	public static final int STOP = 2;

	public static final int STANDBY = 3;

	private int state = NONE;

	private boolean isSpin = false;

	private long nextspintime = 0;
	
	/**
	 * 身上起始金額
	 */
	private BigDecimal goldMoney;

	/**
	 * 身上最終金額
	 */
	private BigDecimal spinGoldMoney;

	/**
	 * 總回合數
	 */
	private int round;

	/**
	 * 總下注額
	 */
	private BigDecimal totalbet;

	/**
	 * 總得分
	 */
	private BigDecimal totalpayout;

	/**
	 * 單局最高得分
	 */
	private BigDecimal maxWinScore;
	
	/**
	 * 紅利遊戲或全盤記數
	 */
	private int bonusCount;

	/**
	 * 第一次離線SPIN的時間
	 */
	private long startTime;

	public SlotOfflineSpinInfoBase() {
		round = 0;
		totalbet = BigDecimal.ZERO;
		totalpayout = BigDecimal.ZERO;
		spinGoldMoney = BigDecimal.ZERO;
		goldMoney = BigDecimal.ZERO;
		maxWinScore = BigDecimal.ZERO;
		isSpin = false;
	}
	
	/**
	 * 設定起始金額與最終金額
	 */
	public void setGoldMoneyAndSpinGoldMoney(BigDecimal goldMoney) {
		this.goldMoney = goldMoney;
		this.spinGoldMoney = goldMoney;
	}
	
	/**
	 * 增加回合數
	 */
	public int incrRound() {
		this.round++;
		return this.round;
	}
	
	/**
	 * 增加紅利記數一次
	 */
	public void addBonusCount() {
		this.bonusCount++;
	}
	
	/**
	 * 增加得分
	 */
	public void addScore(BigDecimal score){
		if(Helper.isGreaterThanZero(score)){
			
			//累積得分
			totalpayout = Helper.add(totalpayout, score);
			
			//更新最大得分
			if(Helper.isGreater(score, maxWinScore)){
				maxWinScore = score;
			}
		}
	}
	
	/**
	 * 增加下注額
	 */
	public void addBet(BigDecimal bet){
		if(Helper.isGreaterThanZero(bet)){
			
			//累積下注額
			totalbet = Helper.add(totalbet, bet);
		}
	}
	
	/**
	 * 計算身上最後金額
	 */
	public BigDecimal calculateSpinGoldMoneyAndGetGain(){
		
		//總獲得(總得分-總下注)
		BigDecimal gain = Helper.sub(totalpayout, totalbet);
		
		//身上最終金額(起始金額+總獲得)
		spinGoldMoney = Helper.add(goldMoney, gain);
		
		return gain;
	}
	
	public long getNextspintime() {
		return nextspintime;
	}

	public void setNextspintime(long nextspintime) {
		this.nextspintime = nextspintime;
	}

	public boolean isSpin() {
		return isSpin;
	}

	public void setSpin(boolean isSpin) {
		this.isSpin = isSpin;
	}

	public int getState() {
		return state;
	}

	public void setState(int state) {
		this.state = state;
	}

	public String getGoldMoney() {
		return goldMoney.toString();
	}

	public int getRound() {
		return round;
	}

	public void setRound(int round) {
		this.round = round;
	}

	public String getTotalbet() {
		return totalbet.toString();
	}

	public String getTotalpayout() {
		return totalpayout.toString();
	}

	public BigDecimal getSpinGoldMoney() {
		return spinGoldMoney;
	}

	public int getBonusCount() {
		return bonusCount;
	}

	public BigDecimal getMaxWinScore() {
		return maxWinScore;
	}

	public long getStartTime() {
		return startTime;
	}

	public void setStartTime(long startTime) {
		this.startTime = startTime;
	}
}
